<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单打印 - {$row.order_no}</title>
    <style>
        body { font-family: Arial, sans-serif; font-size: 12px; margin: 20px; }
        .header { text-align: center; margin-bottom: 20px; }
        .header h1 { margin: 0; font-size: 18px; }
        .order-info { margin-bottom: 20px; }
        .order-info table { width: 100%; border-collapse: collapse; }
        .order-info td { padding: 5px; border: 1px solid #ddd; }
        .items-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
        .items-table th, .items-table td { padding: 8px; border: 1px solid #ddd; text-align: left; }
        .items-table th { background-color: #f5f5f5; }
        .total { text-align: right; font-weight: bold; font-size: 14px; }
        .footer { margin-top: 30px; text-align: center; font-size: 10px; color: #666; }
        @media print {
            .no-print { display: none; }
        }
    </style>
</head>
<body>
    <div class="no-print" style="margin-bottom: 20px;">
        <button onclick="window.print()" class="btn btn-primary">打印订单</button>
        <button onclick="window.close()" class="btn btn-default">关闭</button>
    </div>

    <div class="header">
        <h1>订单详情</h1>
        <p>订单号：{$row.order_no}</p>
    </div>

    <div class="order-info">
        <table>
            <tr>
                <td width="100"><strong>下单时间：</strong></td>
                <td>{$row.createtime|date="Y-m-d H:i:s",###}</td>
                <td width="100"><strong>订单状态：</strong></td>
                <td>{$row.order_status_text}</td>
            </tr>
            <tr>
                <td><strong>支付方式：</strong></td>
                <td>{$row.pay_type_text}</td>
                <td><strong>实付金额：</strong></td>
                <td style="color: red; font-weight: bold;">￥{$row.pay_amount}</td>
            </tr>
            {if condition="$row.user"}
            <tr>
                <td><strong>用户名：</strong></td>
                <td>{$row.user.username}</td>
                <td><strong>手机号：</strong></td>
                <td>{$row.user.mobile|default=''}</td>
            </tr>
            {/if}
            {if condition="$row.userAddress"}
            <tr>
                <td><strong>收货人：</strong></td>
                <td>{$row.userAddress.name}</td>
                <td><strong>联系电话：</strong></td>
                <td>{$row.userAddress.mobile}</td>
            </tr>
            <tr>
                <td><strong>收货地址：</strong></td>
                <td colspan="3">{$row.userAddress.province} {$row.userAddress.city} {$row.userAddress.district} {$row.userAddress.address}</td>
            </tr>
            {/if}
        </table>
    </div>

    <table class="items-table">
        <thead>
            <tr>
                <th>商品名称</th>
                <th>规格</th>
                <th>单价</th>
                <th>数量</th>
                <th>小计</th>
            </tr>
        </thead>
        <tbody>
            {volist name="row.orderItems" id="item"}
            <tr>
                <td>{$item.product_name}</td>
                <td>{$item.product_sku.sku_name|default='默认规格'}</td>
                <td>￥{$item.price}</td>
                <td>{$item.quantity}</td>
                <td>￥{$item.total_amount}</td>
            </tr>
            {/volist}
        </tbody>
    </table>

    <div class="total">
        <p>商品总价：￥{$row.total_amount}</p>
        <p>运费：￥{$row.freight_amount}</p>
        <p>优惠金额：￥{$row.discount_amount}</p>
        <p style="font-size: 16px; color: red;">实付金额：￥{$row.pay_amount}</p>
    </div>

    {if condition="$row.remark"}
    <div style="margin-top: 20px;">
        <strong>订单备注：</strong>{$row.remark}
    </div>
    {/if}

    <div class="footer">
        <p>打印时间：{:date('Y-m-d H:i:s')}</p>
    </div>
</body>
</html>